package com.ymatou.iapi.livebuyer.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.livebuyer.parameter.SyncLiveSellerTopBean;
import com.ymatou.iapi.livebuyer.service.SyncLiveSellerTopCall;
import com.ymatou.iapi.liveseller.parameter.CreateSellerLiveBean;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.LiveRoomCallService;
import com.ymttest.database.model.LiveRoom;
import com.ymttest.database.model.LiveSellerTop;
import com.ymttest.database.sqlwapper.LiveRoomWapper;
/**
*同步直播间主播排名
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_SyncLiveSellerTop{
	private static SyncLiveSellerTopBean synclivesellertopBean;
	private static SyncLiveSellerTopCall synclivesellertopCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("同步直播间主播排名");
	}

	@Before
	public void caseUp() {
		synclivesellertopBean=new SyncLiveSellerTopBean();
		synclivesellertopCall=new SyncLiveSellerTopCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(synclivesellertopCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_SyncLiveSellerTop_001() {
		Logger.start(true,"同步直播间主播排名成功");
		try {
			CreateSellerLiveBean initcreatebean = LiveRoomCallService.initCreatesellerliveBean(null);
			LiveRoom livedto = LiveRoomCallService.CreateSellerLive(initcreatebean);
			Integer liveId = livedto.getId();
			LiveRoomCallService.SellerLiveOnline(liveId, initcreatebean.getLiveDto().getUserId());
			synclivesellertopBean.setSellerId(initcreatebean.getLiveDto().getUserId());
			synclivesellertopBean.setLiveId(liveId);
			synclivesellertopBean.setTopNum(2);
			synclivesellertopBean.setLiveCategory(1);
			synclivesellertopCall.setData(synclivesellertopBean);
			synclivesellertopCall.callService();			
			Logger.verifyEquals("ok", synclivesellertopCall.getReturnData(), "验证返回");
			LiveSellerTop toplive = new LiveRoomWapper().selectLiveSellerTopByExample(initcreatebean.getLiveDto().getUserId());
			Logger.debug(FormatUtil.beanToGSONString(toplive));
			Logger.verifyEquals(synclivesellertopBean.getTopNum(), toplive.getTopNum(), "验证topnum");
			Logger.verifyEquals(synclivesellertopBean.getLiveId(), toplive.getLiveId(), "验证liveid");
			Logger.verifyEquals(synclivesellertopBean.getLiveCategory(), toplive.getLiveCategoryId(), "验证LiveCategoryId");
			Logger.verifyNotNull(toplive.getLiveCategoryName(), "验证LiveCategoryName");
			//TODO 检查日志发送消息 "TopLink\":\"https://m.ymatou.com/evt2/n756?winType=16&tabid=1\
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}